package com.audaque.springboot.foshanupload.session.config;


import com.audaque.springboot.foshanupload.authcore.properties.LoginProperties;
import com.audaque.springboot.foshanupload.core.constants.ComConst;
import com.audaque.springboot.foshanupload.core.properties.StaticResourcePathProperties;
import com.audaque.springboot.foshanupload.session.interceptor.SessionLoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.w3c.dom.stylesheets.LinkStyle;

import java.util.List;

@Configuration
public class RedisHttpSessionInterceptorConfig implements WebMvcConfigurer {
    @Autowired
    public SessionLoginInterceptor sessionLoginInterceptor;
    @Autowired
    private LoginProperties loginProperties;
    @Autowired
    private StaticResourcePathProperties staticResourcePathProperties;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //表示要拦截
        String[] addPathPatterns = {
                ComConst.INTERCEPTOR_ANY_MATCH
        };
        //要排除的路径
        List<String> excludePathPatterns = staticResourcePathProperties.getList();
        registry.addInterceptor(sessionLoginInterceptor).addPathPatterns(loginProperties.getLoginUrl()).order(1);
    }


}
